//
//  CityViewController.m
//  09-HomeWork
//
//  Created by dllo on 16/7/26.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "CityViewController.h"
#import "ZoneViewController.h"
#define kTableViewCellReuse @"reuse"
@interface CityViewController ()<UITableViewDelegate,UITableViewDataSource>
@property (nonatomic, strong)UITableView *tableView;
@end

@implementation CityViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title = _provinceName;
    
    self.tableView = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStylePlain];
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    [self.view addSubview:self.tableView];
    [self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:kTableViewCellReuse];
}

#pragma mark - 点击推出区页面方法
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    NSMutableArray *zoneArr = [_cityArray[indexPath.row] objectForKey:@"zoneArray"];
    ZoneViewController *zoneVC = [[ZoneViewController alloc] init];
    zoneVC.cityName = [_cityArray[indexPath.row] objectForKey:@"cityName"];
    zoneVC.zoneArray = zoneArr;
    [self.navigationController pushViewController:zoneVC animated:YES];
    
}
#pragma mark - dataSource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return _cityArray.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:kTableViewCellReuse];
    cell.textLabel.text = [_cityArray[indexPath.row] objectForKey:@"cityName"];
    return cell;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
